Crate libafl_bolts
source ·Expand description
Welcome to LibAFL_bolts
LibAFL_bolts: OS and Fuzzer Dev’s Libary Collection.
The libafl_bolts
crate exposes a lot of low-level features of LibAFL for projects that are unrelated to fuzzing, or just fuzzers completely different to LibAFL.
Some cross-platform things in bolts include (but are not limited to):
- SerdeAnyMap: a map that stores and retrieves elements by type and is serializable and deserializable
- ShMem: A cross-platform (Windows, Linux, Android, MacOS) shared memory implementation
- LLMP: A fast, lock-free IPC mechanism via SharedMap
- Core_affinity: A maintained version of
core_affinity
that can be used to get core information and bind processes to cores - Rands: Fast random number generators for fuzzing (like RomuRand)
- MiniBSOD: get and print information about the current process state including important registers.
- Tuples: Haskel-like compile-time tuple lists
- Os: OS specific stuff like signal handling, windows exception handling, pipes, and helpers for
fork
LibAFL_bolts is written and maintained by
- Andrea Fioraldi andrea@aflplus.plus
- Dominik Maier dominik@aflplus.plus
- s1341 github@shmarya.net
- Dongjia Zhang toka@aflplus.plus
- Addison Crump me@addisoncrump.info
Contributing
For bugs, feel free to open issues or contact us directly. Thank you for your support. <3
Even though we will gladly assist you in finishing up your PR, try to
- keep all the crates compiling with stable rust (hide the eventual non-stable code under
cfg
s) - run
cargo fmt
on your code before pushing - check the output of
cargo clippy --all
or./clippy.sh
- run
cargo build --no-default-features
to check forno_std
compatibility (and possibly add#[cfg(feature = "std")]
) to hide parts of your code.
Some of the parts in this list may be hard, don’t be afraid to open a PR if you cannot fix them by yourself, so we can help.
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Dependencies under more restrictive licenses, such as GPL or AGPL, can be enabled using the respective feature in each crate when it is present, such as the 'agpl' feature of the libafl crate.
Feature Flags
General Features
-
std
(enabled by default) — Enables features that need rust’sstd
lib to work, like print, env, … support -
alloc
(enabled by default) — Enables all features that allocate inno_std
-
derive
(enabled by default) — Provide the#[derive(SerdeAny)]
macro. -
rand_trait
(enabled by default) — If set, libafl_bolt’srand
implementations will implementrand::Rng
-
python
— Will build thepyo3
bindings -
prelude
(enabled by default) — Exposelibafl::prelude
for direct access to all types without additionaluse
directives -
cli
— Exposelibafl_bolts::cli
for easy commandline parsing of common fuzzer settings -
qemu_cli
— Enables extra commandline flags for qemu-based fuzzers incli
-
frida_cli
— Enables extra commandline flags for frida-based fuzzers incli
-
errors_backtrace
— Stores the backtraces of all generatedError
s. Good for debugging, but may come with a slight performance hit. -
gzip
(enabled by default) — Enables gzip compression in certain parts of the lib -
xxh3
(enabled by default) — Replacesahash
with the potentially fasterxxh3
in some parts of the lib. This yields a stable and fast hash, but may increase the resulting binary size slightly This also enables certain hashing and rand features inno_std
no-alloc.
SerdeAny features
serdeany_autoreg
(enabled by default) — Automatically register all#[derive(SerdeAny)]
types at startup.
LLMP features
-
llmp_bind_public
— If set, llmp will bind to 0.0.0.0, allowing cross-device communication. Binds to localhost by default. -
llmp_compression
(enabled by default) — Enables llmp compression using GZip -
llmp_debug
— Enables debug output for LLMP (also needs alogger
installed) -
llmp_small_maps
(enabled by default) — Reduces the initial map size for llmp
Modules
- Poor-rust-man’s downcasts to have
AnyMap
- The purpose of this module is to alleviate imports of the bolts by adding a glob import.
- Based on https://github.com/alecmocatta/build_id (C) Alec Mocatta alec@mocatta.net under license MIT or Apache 2
- A one-size-fits-most approach to defining runtime behavior of
LibAFL
fuzzers - Compression of events passed between a broker and clients. Currently we use the gzip compression algorithm for its fast decompression performance.
- This crate manages CPU affinities.
- Architecture agnostic processor features
LibAFL
functionality for filesystem interaction- launcherDeprecatedDummy module informing potential users that the launcher module has moved out of
libafl_bolts
intolibafl::events::launcher
. - A library for low level message passing
- Math-related functions that we commonly (or at least sometimes) need
- Implements a mini-bsod generator. It dumps all important registers and prints a stacktrace. You may use the
crate::os::unix_signals::ucontext
function to get aucontext_t
. - Operating System specific abstractions
- Wrappers that abstracts references (or pointers) and owned data accesses.
- The purpose of this module is to alleviate imports of many components by adding a glob import.
- The random number generators of
LibAFL
- Poor-rust-man’s downcasts for stuff we send over the wire (or shared maps)
- A generic shared memory region to be used by any functions (queues or feedbacks too.)
- Stores and restores state when a client needs to relaunch. Uses a
ShMem
up to a threshold, then write to disk. - Compiletime lists/tuples used throughout the
LibAFL
universe
Macros
- Create
AnyMap
andNamedAnyMap
for a given trait - Register a
SerdeAny
type in theRegistryBuilder
- Implement
AsAny
for a type - Implement a
SerdeAny
, registering it in theRegistryBuilder
when on std - Iterate over a tuple, executing the given
expr
for each element. - Iterate over a tuple, executing the given
expr
for each element, granting mut access.
Structs
- The client ID == the sender id.
- A simple logger struct that logs to a
RawFd
when used withlog::set_logger
. - A simple logger struct that logs to stderr when used with
log::set_logger
. - A simple logger struct that logs to stdout when used with
log::set_logger
.
Enums
- Main error struct for
LibAFL
Statics
- Stderr logger
- Stdout logger
Traits
- Create an
Iterator
from a reference - Create an
Iterator
from a mutable reference - Can be converted to a mutable slice
- Can be converted to a slice
- Has a length field
- Has a ref count
- Trait to convert into an Owned type
- We need fixed names for many parts of this lib.
- Trait to truncate slices and maps to a new size
Functions
- Gets current milliseconds since
UNIX_EPOCH
- Gets current nanoseconds since
UNIX_EPOCH
- Current time
- Format a
Duration
into a HMS string
Type Aliases
- Error Backtrace type when
errors_backtrace
feature is enabled (==backtrace::Backtrace
)
Derive Macros
- Derive macro to implement
SerdeAny
, to use a type in aSerdeAnyMap